﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CompositionPlugin
{
    public interface IDefaultMetadata { }

    public class ImportedPlugin<T>
    {
        public ImportedPlugin(T plugin)
        {
            this.Plugin = plugin;
        }

        public T Plugin { get; private set; }
    }

    public class ImportedPlugin<T, TMetadata> : ImportedPlugin<T>
    {
        public ImportedPlugin(T plugin, TMetadata metadata)
            : base(plugin)
        {
            this.Metadata = metadata;
        }

        public TMetadata Metadata { get; private set; }

        public override bool Equals(object obj)
        {
            if (obj is ImportedPlugin<T, TMetadata>)
            {
                return object.ReferenceEquals(this.Plugin, (obj as ImportedPlugin<T, TMetadata>).Plugin);
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            return this.Metadata.GetHashCode() + this.Plugin.GetHashCode();
        }
    }
}
